<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/7/26
  Time: 8:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <meta charset="UTF-8">
    <title>爱购我的订单</title>
    <link rel="stylesheet" href="${ctx}/static/front/css/reset.css"/>
    <link rel="stylesheet" href="${ctx}/static/front/css/top.css"/>
    <link rel="stylesheet" href="${ctx}/static/front/css/buyerTrade.css"/>
    <link rel="stylesheet" href="${ctx}/static/front/css/footer.css"/>
    <link rel="stylesheet" href="${ctx}/static/front/css/font-awesome-4.7.0/Font-Awesome-master/css/font-awesome.min.css"/>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <link rel="stylesheet" href="${ctx}/static/js/layui/css/layui.css">
</head>
<body>
<!--头部-->
<div class="top" id="top">
    <!--头部bar-->
    <div class="top-bar">
        <div class="w1230 top-main">
            <a href="${ctx}/front/frontUser/goindex" class="toIndex">
                <i class="fa fa-home"></i>
                <span>爱购网首页</span>
            </a>
            <div class="account">
                <span>${frontUser.username}<i class="fa fa-caret-down"></i></span>
                <div class="manage">
                    <ul>
                        <li><a href="${ctx}/front/address/goDeliverAddress">收货地址</a></li>
                        <li><a href="${ctx}/front/cart/goBuyerTrade">购物车</a></li>
                        <li><a href="${ctx}/orders/goBuyerTrade">我的订单</a></li>
                        <li><a href="${ctx}/front/frontUser/frontLogOut">退出</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="w1230">
    <img src="${ctx}/static/front/img/logo.png" width="100" height="40" class="logo"/>
    <span class="cart">我的订单</span>
</div>
<!--订单列表-->
<div class="w1230 trade">
    <!--标题栏-->
    <div class="trade-title">
        <ul class="clear-float">
            <li class="info">宝贝</li>
            <li class="price">单价</li>
            <li class="num">数量</li>
            <li class="real-price-title">实付款</li>
            <li class="operate">交易操作</li>
        </ul>
    </div>
    <!--详细展示-->
    <div class="trade-list">
        <c:forEach items="${orders}" var="order">
            <div>
                <div class="trade-list-top clear-float">
                    <div class="trade-list-l">
                        <span class="trade-date"><fmt:formatDate value="${order.createTime}" pattern="yyyy-MM-dd HH:mm:ss" /></span>
                        <span class="trade-no">订单号:${order.id}</span>
                    </div>
                    <a href="#" class="delete" data-orderId="${order.id}" ><i class="fa fa-trash trade-list-r"></i></a>
                </div>
                <c:forEach items="${orderComs}" var="orderCom">
                    <c:if test="${order.id==orderCom.orderId}">
                        <div>
                            <ul class="clear-float">
                                <li class="info">
                                    <img src="${ctx}/user/getImage?name=${orderCom.img}"/>
                                    <p>${orderCom.name}</p>
                                </li>
                                <li class="price">￥${orderCom.price}</li>
                                <li class="num">${orderCom.counts}</li>
                                <li class="real-price">￥${orderCom.price*orderCom.counts}</li>
                                <li class="operate"><a href="#" class="buyAgain" data-comId="${orderCom.comId}">再次购买</a></li>
                            </ul>
                        </div>
                    </c:if>
                </c:forEach>
            </div>
        </c:forEach>
    </div>
</div>
<!--脚注-->
<div class="footer">
    <p class="w1230">
        <a href="#">关于爱购</a>
        <a href="#">合作伙伴</a>
        <a href="#">营销中心</a>
        <a href="#">廉正举报</a>
        <a href="#">联系客服</a>
        <a href="#">开发平台</a>
        <a href="#">诚征英才</a>
        <a href="#">联系我们</a>
        <a href="#">网站地图</a>
        <a href="#">知识产权</a><span>|</span>
        <span>&copy;2018-2020 igo.com 版权所有</span>
    </p>
</div>
<script src="${ctx}/static/js/layui/layui.js"></script>
<script>

    //删除选中的订单
    $(".delete").on("click",function () {
        var orderId = $(this).data("orderid");

        $.post("${ctx}/orders/deleteOrder",
            {"orderId" : orderId},
            function (data) {
                if (data==""){
                    $(window).attr("location","${ctx}/orders/goBuyerTrade");
                }else{
                    parent.layer.msg(data, {icon: 5});
                }
            })
    })

    //点击再次购买
    $(".buyAgain").on("click",function () {
        var comId = $(this).data("comid");
        $(this).attr("href" ,"${ctx}/front/index/commodityDetails?commodityId="+comId);
    })
</script>
</body>
</html>
